home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / COMM / ANSI_133 / POORMAN.PAS < prev    next >
Pascal/Delphi Source File  |  1990-07-10  |  3KB  |  84 lines

  1. {$V-,R-,S-,O+}
  2. { PoorMan's replacement for certain Turbo Power routines used in PingAnsi. }
  3. { The routines in this unit are adapted from routines supplied by          }
  4. { Robert Mashlan (1:147/34.33) and Trevor Carlsen (3:690/644) for this     }
  5. { very purpose.                                                            }
  6.  
  7. Unit PoorMan;
  8.  
  9. Interface
  10. Uses Crt;
  11.  
  12. Procedure StuffString(Var St : String);
  13. Function Long2Str(n : LongInt) : String;
  14. Procedure ScrollWindowDown(XLo, YLo, XHi, YHi, Lines : Byte);
  15.  
  16. Implementation
  17.  
  18.   Function InsertKey(key : Word) : Boolean;
  19.   {-Insert a key into the keyboard buffer. Key must be passed
  20.     with the MSB being the scan code of the key you want inserted
  21.     and the LSB being the ascii code. For keys that return an
  22.     extended code (cursor keys function keys etc.) the LSB must be
  23.     zero and the MSB the scan code. Returns true if successfull. }
  24.   Var
  25.     OldTail        : Word;
  26.     BufferStart    : Word absolute $40:$80;         {-Address of the keyboard buffer  }
  27.     BufferEnd      : Word absolute $40:$82;
  28.     Head           : Word absolute $40:$1A;
  29.     Tail           : Word absolute $40:$1C;
  30.  
  31.   Begin
  32.     InsertKey := True;
  33.     MemW[$0040:tail] := key;      {-Insert the keypress             }
  34.     OldTail := tail;              {-Keep record of tail position in }
  35.     {-case the key buffer was full    }
  36.     If tail = BufferEnd Then      {-wrap around to Start of buffer  }
  37.       tail := BufferStart
  38.     Else
  39.       Inc(tail, 2);               {-To allow for newly inserted key }
  40.     If tail = head Then
  41.     Begin {-No room for inserting the key so}
  42.       tail := OldTail;            {-restore the status quo          }
  43.       InsertKey := False;
  44.     End;                          {-if tail = head}
  45.   End;                            {-InsertKey}
  46.  
  47.   Procedure StuffString(Var St : String);
  48.     {-stuff st into the keyboard buffer}
  49.   Var
  50.     x              : Byte;
  51.     sa             : Array[0..16] Of Byte Absolute St;
  52.   Begin
  53.     x := 0;
  54.     Repeat                        {-until the buffer is full or }
  55.       Inc(x);
  56.     Until Not InsertKey(sa[x]) Or (x = sa[0]);
  57.   End;
  58.  
  59.   Function Long2Str(n : LongInt) : String;
  60.   Var s          : String;
  61.   Begin
  62.     Str(n, s);
  63.     Long2Str := s;
  64.   End;
  65.  
  66.   Procedure ScrollWindowDown(XLo, YLo, XHi, YHi, Lines : Byte);
  67.   Var
  68.     SavedWindMax, SavedWindMin : Word;
  69.     SavedX, SavedY, i : Byte;
  70.   Begin
  71.     SavedWindMax := WindMax;
  72.     SavedWindMin := WindMin;
  73.     SavedX := wherex;
  74.     SavedY := wherey;
  75.     window(XLo, YLo, XHi, YHi);
  76.     For i := 1 To Lines Do insline;
  77.     WindMax := SavedWindMax;
  78.     WindMin := SavedWindMin;
  79.     GotoXY(SavedX, SavedY);
  80.   End {ScrollWindowDown} ;
  81.  
  82. End.
  83.  
  84.